  var object={};

   
$(function(){

	YuXi.InfoQuery.init({	
		url:"FirstCheckFilter/firstCheckGetList.do",
		query:{
				
				
				currentPage:1
			},					
		success:function(data){	
			object=data.list;				
				YuXi.Render.InformationSeach(data.list,3,"初审");//调用信息查询的页面渲染模块
			},
			getQueryParm:function(){
						var query={};
						query={
						
							currentPage:1
						}
						YuXi.InfoQuery.queryData=YuXi.ALLSearch.base();
					},
				error:function(){},
				/* selector:{
					nextPage:$("#nextPage"),
					prevPage:$("#prevPage"),
					firstPage:$("#headPage"),
					lastPage:$("#endPage"),
					totalPage:$("#totalPage")
					此项为默认项
				}	 */
		});	
    $(document).on("click",".detail",function(){
	  var id= $(this).attr("data-id");
		var menuId=$("#menu-container").attr("menu-id");
		window.location.href = '../information/subDetailInfo.jsp?menuId='+menuId+'&detailId=' + id;
  });
 
   //跳转到修改页面
	$(document).on("click",".update",function(){
		 var id= $(this).attr("data-id");
		 var flowId= $(this).attr("data-flowId");
		 var menuId=$("#menu-container").attr("menu-id");
		 window.location.href='updateInfo.jsp?updateId=' + id + '&flowId=' + flowId+"&menuId="+menuId;
	});
 
  
  
	 
 // 初审汇总表------------------------
  $("#ExcelFrist").click(function(){
		$(".modal-export").modal("show"); 
  })
  //提交
  $(".insert").click(function(){
	  insertid="id="+$(this).attr("data-id");
	  $("#Mymodal").modal('show');
  })
  //提交模态框按钮
  $("#sure").click(function(){
	
	  requestSure(insertid);//调用提交方法;
  })
  //合并按钮点击
  $("#requestTogether").click(function(){
	  var togetherObject=[];
	 //alert("object"+JSON.stringify(object));
	  endId=[];//让选中ID清空;
	    $("input[name='together']:checked").each(function () {	    	  
	    	
	    	endId.push(this.value);
	    	var flag=this.getAttribute("data-index");
	          togetherObject.push(object[flag-1]);
	     });
		if(endId.length<=0)
		{
			myTool.alert({		
			title:"提示",
			context:"还未选中需要合并的信息",
			isMask:true,
			callback:function(){
			
				return false;
	 		 //alert(JSON.stringify(object3)+"id"+id);
	 		
				}
			});
			return false;
		}
	   var html='<table class="table table-striped table-bordered" ><thead><tr><th>编号</th><th >信息简介</th>'+
	   			'<th >参 与 人</th><th >信息建立时间</th></tr></thead><tbody id="togetherbody">'+
	   			'<!-- 数据填充 --></tbody></table>';
	    $("#informationTo").html(html);//将值填充到模态框中
	    $("#togetherbody").html("");

	    for(var i=0;i<togetherObject.length;i++)
	    {	
	    	var object2=togetherObject[i];
	    	//模拟数据
	    	if(object2.informationProfile.length>20)
	    		object2.informationProfile= object2.informationProfile.substring(0,15)+"...";
	    	//cons
	    	var time=YuXi.getTime.get(object2.createTime);
	    	
	    	var html="<tr ><td><input value="+object2.id+" type='radio' name='togetherRadio' data-id="+(i+1)+" > "+object2.id+"</td><td >"+object2.informationProfile+"</td>"+
	    	"<td >"+object2.inputPerSonNames+"</td><td >"+time+"</td><tr>";
	    	$("#togetherbody").append(html);
	    } 

	   $("#togethermodel").modal('show');
	   
  })
  //合并模态框数据
  $("#sureTogether").click(function(){
  		 var id=$("input[name='togetherRadio']:checked").val();  
  		 
  		 if(id=="" || id==undefined || id=="undefined")
  		 {
  		 		myTool.alert({		
					title:"提示",
					context:"还未选中模板",
					isMask:true,
					callback:function(){
						return false;
						}
			});
  		 }
  		 else
  		 {
  		 	myTool.alert({		
			title:"提示",
			context:"将会删除合并信息,并新建一条信息，是否确认？",
			isMask:true,
			callback:function(){
	 	 		requestTogether(endId,id);//结束多余的信息
			}
		});
  		 }
  })
//合并-结束选中的id
function requestTogether(endid,id)
{
	var url="infoTogether.do";
	var information={};
	information.enId=endid.join(",");
	information.temId=id;
	
	
	 YuXi.util.get(url,information,function(data){

		window.location.href='combiningTrial.jsp?updateId='+data.object.id+'&flowId=1';
	   },function(){
	   })
}


})